﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>    


		<head>
		<script type="text/javascript" src="<c:url value='/easyui/datagrid-detailview.js'/>"></script>
  
		    <script type="text/javascript"> 
			$(function(){
				
				  init();
			  
			});

			function init(){
				
				$('#t-dg').datagrid({
				loadMsg:'',
				view:detailview,
				onDblClickRow:function(rowIndex, rowData){
					$('#t-dg').datagrid('expandRow',rowIndex);
                },
				rowStyler:function(index,row){  
			        if(row.timeout <= 0){               
		                return 'background-color:${cfgs["expbgcolor"]};color:${cfgs["expfgcolor"]};font-weight:bold;';    
		            }   
		        },
				detailFormatter:function(index,row){
				  var content = '';
          
          content += '<span style="color:blue;font-weight:700">方式：</span></br>';
content += '<div style="padding:5px">'+ row.op_mode.replace(/\r\n/gi,'<br/>')+'</div>';
content += '<span style="color:blue;font-weight:700">类型：</span></br>';
content += '<div style="padding:5px">'+ row.op_type.replace(/\r\n/gi,'<br/>')+'</div>';

          
          if (row.unitname)  {
   content += '<span style="color:blue;font-weight:700">单位名称：</span></br>';
   content += '<div style="padding:5px">'+ row.unitname.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.editdate)  {
   content += '<span style="color:blue;font-weight:700">录入时间：</span></br>';
   content += '<div style="padding:5px">'+ row.editdate.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.valid_time_hint)  {
   content += '<span style="color:blue;font-weight:700">过期时间：</span></br>';
   content += '<div style="padding:5px">'+ row.valid_time_hint.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.address)  {
   content += '<span style="color:blue;font-weight:700">地址：</span></br>';
   content += '<div style="padding:5px">'+ row.address.replace(/\r\n/gi,'<br/>')+'</div>';
}

if (row.mj)  {
	   content += '<span style="color:blue;font-weight:700">面积：</span></br>';
	   content += '<div style="padding:5px">'+ row.mj.replace(/\r\n/gi,'<br/>')+'</div>';
	}
	if (row.tx)  {
	   content += '<span style="color:blue;font-weight:700">套型：</span></br>';
	   content += '<div style="padding:5px">'+ row.tx.replace(/\r\n/gi,'<br/>')+'</div>';
	}
	if (row.lc)  {
	   content += '<span style="color:blue;font-weight:700">楼层：</span></br>';
	   content += '<div style="padding:5px">'+ row.lc.replace(/\r\n/gi,'<br/>')+'</div>';
	}
	if (row.jg)  {
	   content += '<span style="color:blue;font-weight:700">价格：</span></br>';
	   content += '<div style="padding:5px">'+ row.jg.replace(/\r\n/gi,'<br/>')+'</div>';
	}
	if (row.zx)  {
	   content += '<span style="color:blue;font-weight:700">装修：</span></br>';
	   content += '<div style="padding:5px">'+ row.zx.replace(/\r\n/gi,'<br/>')+'</div>';
	}
	if (row.lxfs)  {
	   content += '<span style="color:blue;font-weight:700">联系方式：</span></br>';
	   content += '<div style="padding:5px">'+ row.lxfs.replace(/\r\n/gi,'<br/>')+'</div>';
	}
if (row.context)  {
   content += '<span style="color:blue;font-weight:700">内容：</span></br>';
   content += '<div style="padding:5px">'+ row.context.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.memo)  {
   content += '<span style="color:blue;font-weight:700">备注：</span></br>';
   content += '<div style="padding:5px">'+ row.memo.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.oper)  {
   content += '<span style="color:blue;font-weight:700">操作人员：</span></br>';
   content += '<div style="padding:5px">'+ row.oper.replace(/\r\n/gi,'<br/>')+'</div>';
}

           
					return '<div style="padding:5px">' + content + '</div>';
				}
				
			});
				
			}
			
			
			

			
			function deleteItem(){
			var t = $('#t-dg');
			var row = t.datagrid('getSelected');
			if (row){
				
				$.messager.confirm('删除确认', '是否确定要删除选择的需求信息?', function(r){
						if (r){
				$.ajax({
					url:'<c:url value="/myinfo/Demandinfo/destroyDemandinfo"/>?id=' + row.id,
					type:'post',
					success:function(){
						$('#t-dg').datagrid('reload');
					}
				});
			}});
				
			}
		}
		
		function deleteAllItem(){
			
				
				$.messager.confirm('批量删除确认', '是否确定要删除所有过期需求信息?', function(r){
						if (r){
				$.ajax({
					url:'<c:url value="/read/Demandinfo/destroyAllExpiredDemandinfo"/>',
					type:'post',
					success:function(){
						$('#t-dg').datagrid('reload');
					}
				});
			}});
				
			
		}
			
		function updateAllItem(day){
			
				
				$.messager.confirm('批量更新时间确认', '是否确定要更新所有过期需求信息?', function(r){
						if (r){
				$.ajax({
					url:'<c:url value="/read/Demandinfo/updateAllExpiredDemandinfo"/>?day=' + day,
					type:'post',
					success:function(){
						$('#t-dg').datagrid('reload');
					}
				});
			}});
				
			
		}	
			
			
		</script>
	</head>
	<body>
		<div class="easyui-layout" fit="true">
		<div region="north" border="false" style="height:40px;padding:5px;overflow:hidden;">
					<div style="padding-top:6px;float:left;color:blue;font-weight:700">
			请处理以下信息，如已不需要，请删除！
			</div>
		<div style="float:right">
			<a href="#" class="easyui-menubutton" data-options="menu:'#mm1',iconCls:'icon-search'">批量更新时间</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="deleteAllItem()">批量删除</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteItem()">删除选择</a>
		</div>
		<div id="mm1" style="width:100px;">
		<div onclick="javascript:updateAllItem(3);">&nbsp;三天</div>
		<div onclick="javascript:updateAllItem(7);">&nbsp;一周</div>
		<div onclick="javascript:updateAllItem(31);">&nbsp;一月</div>
		<div onclick="javascript:updateAllItem(91);">&nbsp;三月</div>
		<div onclick="javascript:updateAllItem(182);">&nbsp;半年</div>
		<div onclick="javascript:updateAllItem(365);">&nbsp;一年</div>
  	</div>
		</div>	
			<div region="center" border="true">
	      <table id="t-dg" style="display:none;"
						url="<c:url value='/read/Demandinfo/getExpiredDemandinfoItems'/>"
						singleSelect="true" rownumbers="true" pagination="true"
						border="false" fit="true" fitColumns="false">
					<thead>
						<tr>
							<th field="unitname" width="100" sortable="true">单位名称</th>
<th field="editdate" width="100" sortable="false">录入时间</th>
<th field="op_mode" width="100" sortable="true" >方式</th>
<th field="op_type" width="100" sortable="true" >类型</th>
<th field="valid_time_hint" width="100" sortable="false">过期时间</th>
<th field="address" width="100" sortable="true">地址</th>
<th field="mj" width="100" sortable="true">面积</th>
<th field="tx" width="100" sortable="true">套型</th>
<th field="lc" width="100" sortable="true">楼层</th>
<th field="jg" width="100" sortable="true">价格</th>
<th field="zx" width="100" sortable="false">装修</th>
<th field="lxfs" width="100" sortable="false">联系方式</th>
<th field="context" width="100" sortable="false">内容</th>
<th field="memo" width="100" sortable="false">备注</th>
<th field="oper" width="100" sortable="true">操作人员</th>

						</tr>
					</thead>
				</table>			
			</div>
		</div>
		
		
		
			
		
		
		
		
	</body>
